<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>捕捉元素</title>
	<style type="text/css">
		.box{
			width:200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
		}

	</style>
	<script type="text/javascript">

		window.onload = function  () {

			var dd = document.getElementsByTagName('div');
			console.log(dd);

			// dd[0].style.background="blue";

			var dd = document.getElementById('box1');

			// dd.style.background='blue';

			// console.log(dd);
			var dd = document.getElementsByClassName('box');

			dd[0].style.background="blue";
			dd[0].style.width="300px";
			// console.log(dd);
		}
	</script>

</head>
<body>
	<div class="box" id="box1">
		1
	</div>
	<div class="box" id="box2">
		2
	</div>
</body>
</html>